import { http } from '@/utils/request'
import type {
  Test,
  TestCreateRequest,
  TestUpdateRequest,
  TestListRequest,
  TestListResponse
} from '@/types/api'

// 获取测试列表
export const getTests = (params?: TestListRequest): Promise<TestListResponse> => {
  return http.get('/api/v1/tests', { params })
}

// 获取测试详情
export const getTest = (id: number): Promise<Test> => {
  return http.get(`/api/v1/test/${id}`)
}

// 创建测试
export const createTest = (data: TestCreateRequest): Promise<Test> => {
  return http.post('/api/v1/test', data)
}

// 更新测试
export const updateTest = (id: number, data: TestUpdateRequest): Promise<Test> => {
  return http.put(`/api/v1/test/${id}`, data)
}

// 删除测试
export const deleteTest = (id: number): Promise<void> => {
  return http.delete(`/api/v1/test/${id}`)
}
